package aparicio.mbox.parse;

public class Program {

	/**Main entry point for the program
	 * 
	 * @param args .mbox files to parse
	 */
	public static void main(String[] args) {
		// check that arguments are given
		if (args.length < 1) {
			System.out.println("No arguments given");
			return;
		}
		
		// check that given arguments are .mbox files to parse
		for (String file: args) {
			if (!file.contains(".mbox")){
				System.out.println("Argument specified is not a .mbox file");
				return;
			}
		}
		
		// set up the email parser
		EmailParser parser = new EmailParser(args);
		
		// parse all given emails
		try {
			parser.parseAll();
		} catch (Exception e) {
			System.out.println("Failed to correctly parse the emails: "
					+ e.getMessage());
		}
		
		// print the statistics from the emails
		try {
			parser.printStats();
		} catch (Exception e) {
			System.out.println("Failed to print the email statistics: "
					+ e.getMessage());
		}
	}
}
